//
//  StackBtnCollectionViewCell.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/6.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "StackBtnCollectionViewCell.h"


@interface StackBtnCollectionViewCell ()
@property (strong, nonatomic) UIImageView *iconIV;
@property (strong, nonatomic) UILabel *nameL;
@end

@implementation StackBtnCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self == [super initWithFrame:frame]) {
        
        [self.contentView addSubview:self.iconIV];
        [self.contentView addSubview:self.nameL];
        
    }
    
    return self;
}

- (void)setCategoryModel:(SupportCategoryModel *)categoryModel {
    
    _categoryModel = categoryModel;
    
    [self.iconIV sd_setImageWithURL:[NSURL URLWithString:categoryModel.pic]];
    self.nameL.text = categoryModel.name;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.iconIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(weakSelf.contentView.mas_top).with.offset(jisuan(16));
        make.centerX.mas_equalTo(weakSelf.contentView.mas_centerX);
        make.width.mas_equalTo(jisuan(54));
        make.height.mas_equalTo(jisuan(54));
    }];
    
    [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.contentView.mas_centerX);
        make.top.mas_equalTo(weakSelf.iconIV.mas_bottom).with.offset(jisuan(20));
        make.bottom.mas_equalTo(weakSelf.contentView.mas_bottom).with.offset(-jisuan(15));
    }];
}

#pragma mark -lazy
- (UIImageView *)iconIV {
    
    if (!_iconIV) {
        
        _iconIV = [[UIImageView alloc] init];
        _iconIV.contentMode = UIViewContentModeScaleAspectFit;
    }
    
    return _iconIV;
}

- (UILabel *)nameL {
    
    if (!_nameL) {
        
        _nameL = [[UILabel alloc] init];
        _nameL.textColor = Color333333;
        _nameL.font = Font(24);
    
    }
    
    return _nameL;
}

@end
